﻿

                         <div class="col-md-12">
								<!-- BOX -->
								<div class="box border green">
									<div class="box-title">
										<h4><i class="fa fa-table"></i>Dynamic Data Tables</h4>
										<div class="tools hidden-xs">
											<a href="#box-config" data-toggle="modal" class="config">
												<i class="fa fa-cog"></i>
											</a>
											<a href="javascript:;" class="reload">
												<i class="fa fa-refresh"></i>
											</a>
											<a href="javascript:;" class="collapse">
												<i class="fa fa-chevron-up"></i>
											</a>
											<a href="javascript:;" class="remove">
												<i class="fa fa-times"></i>
											</a>
										</div>
									</div>
									<div class="box-body">
									    <form action="" method="post">
										<div id="datatable1_wrapper" class="dataTables_wrapper form-inline" role="grid"><div class="row"><div class="col-sm-12"><div class="pull-right"><div id="datatable1_filter" class="dataTables_filter"><label><input class="form-control input-sm" placeholder="Search" aria-controls="datatable1" type="text"></label></div></div><div class="pull-left"><div class="dataTables_length" id="datatable1_length"><label>Show <select class="form-control input-sm" aria-controls="datatable1" size="1" ><option selected="selected" value="10">10</option><option value="25">25</option><option value="50">50</option><option value="100">100</option></select> Rows</label></div></div><div class="clearfix"></div></div></div><table aria-describedby="datatable1_info" id="datatable1" class="datatable table table-striped table-bordered table-hover dataTable" border="0" cellpadding="0" cellspacing="0">

											<thead>
												<tr role="row">
						<th style="width:50px;"></th>
						<?php foreach($arr as $k=>$v):?>
                        <th aria-label="Rendering engine: activate to sort column descending" aria-sort="ascending" style="width:250px;" colspan="1" rowspan="1" aria-controls="datatable1" tabindex="0" role="columnheader" class="sorting_asc"><?php echo $arr[$k][0]['attr_name']?></th>
                        <?php endforeach;?>
                        <th aria-label="CSS grade: activate to sort column ascending" style="width:200px;" colspan="1" rowspan="1" aria-controls="datatable1" tabindex="0" role="columnheader" class="hidden-xs sorting">数量</th>
						<th aria-label="CSS grade: activate to sort column ascending" style="width:250px;" colspan="1" rowspan="1" aria-controls="datatable1" tabindex="0" role="columnheader" class="hidden-xs sorting">操作</th>
												</tr>
											</thead>

                                        
										<tbody aria-relevant="all" aria-live="polite" role="alert">
										         
										          <tr class="gradeA odd">
										            <td><button type="button" style="width:30px;height:30px;padding:3px" class="btn btn-warning addnum">+</button>
										            </td>
										            <?php foreach($arr as $k=>$v):?>
													<td filed='id' class="sorting_1">
													  <select name='goodsattr[<?php echo $k?>][]' class="form-control" style="width:180px;float:left">
													         <?php foreach($v as $k1=>$v1):?>
													         <option value="<?php echo $v1['id']?>"><?php echo $v1['attr_value']?></option>
													         <?php endforeach;?>
													  </select>
													</td>
													<?php endforeach; ?>													
													<td>
														<div class="col-sm-3">
														  <input name="number[]" class="form-control" type="text">
														</div>
													</td>
													<td><a class="btn btn-default" href="<?php U('admin/goods/update',array('id'=>$r['id']));?>"><i class="fa  fa-pencil"></i> 修改</a></td>
												  </tr>
									  
												</tbody></table>
                                                <input type="hidden" name="id" value="<?php echo $id?>">
												<div class="col-sm-offset-0 col-sm-5">
												<button type="submit" class="btn btn-success">提交</button>
												</div>
												</form>

												<div class="row"><div class="col-sm-12"><div class="pull-left"><div id="datatable1_info" class="dataTables_info">Showing 1 to 10 of 57 entries</div></div><div class="pull-right"><div id="datatable1_paginate" class="dataTables_paginate paging_bs_full">

												<ul class="pagination">




												</ul>
												</div></div><div class="clearfix"></div></div></div></div>
									</div>
								</div>
								<!-- /BOX -->
							</div>
<script src="public/admin/js/jquery/jquery-2.0.3.min.js"></script>
<script type="text/javascript">
$(function(){
   $('tbody').on('click','button',function(){
      
       if($(this).text()=='+'){
			var tr=$(this).parent().parent().clone();
			tr.find('button').text('-');
			$(this).parent().parent().parent().append(tr);
       }else{
			$(this).parent().parent().remove();
       }
       
   });

})
</script>
